package com.gd.coreservice.mapper;

import com.gd.coreservice.entity.Collection;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gd.coreservice.entity.vo.CollectionVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author testjava
 * @since 2024-03-23
 */
public interface CollectionMapper extends BaseMapper<Collection> {
@Select("SELECT * FROM collection LEFT JOIN goods ON collection.item_id=goods.gid WHERE collection.user_id=#{uid} AND (IFNULL(goods.item_name,'') LIKE concat('%',#{item_name}, '%')) ORDER BY created_time DESC")
    List<CollectionVo> findCollection(String uid, @Param("item_name") String itemName);
    @Select("SELECT count(*) FROM collection LEFT JOIN goods ON collection.item_id=goods.gid WHERE collection.user_id=#{uid} AND (IFNULL(goods.item_name,'') LIKE concat('%',#{item_name}, '%')) ")
    Integer getTotal(String uid,  @Param("item_name") String itemName);
}
